using System;

namespace FizzBuzz
{
    internal class DelegateDemo
    {
        public void Run()
        {
            EventHandler d = new EventHandler(DemoMethod);
            d(this, EventArgs.Empty);
            d = DemoMethod;
            d(this, EventArgs.Empty);
            d = delegate(object sender, EventArgs e)
                    {
                        Console.WriteLine("Anonymous method");
                    };
            d(this, EventArgs.Empty);
            d = delegate
                    {
                        Console.WriteLine("Simpler anonymous method");
                    };
            d(this, EventArgs.Empty);

            Func<int, int, string> func = (x, y) => (x*y).ToString();
            Console.WriteLine(func(5, 10));
        }

        private void DemoMethod(object sender, EventArgs e)
        {
            Console.WriteLine("Handled by Demo Method");
        }
    }
}